package com.wish.house.config;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;

import java.io.Serializable;

/**
 * @author yangyang
 * @since 2022.3.2 16:20
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
@Accessors(chain = true)
public class AjaxResult implements Serializable {
    private boolean result;

    private Integer code;

    private Object data;

    private String message;

    public static AjaxResult success(Integer code,Object data,String message){
        return new AjaxResult().setResult(true).setCode(code).setData(data).setMessage(message);
    }

    public static AjaxResult success(){
        return new AjaxResult().setResult(true);
    }

    public static AjaxResult success(Object data){
        return new AjaxResult().setResult(true).setData(data);
    }

    public static AjaxResult error(Integer code,Object data,String message){
        return new AjaxResult().setResult(false).setCode(code).setData(data).setMessage(message);
    }

    public static AjaxResult error(Integer errorCode,String message){
        return new AjaxResult().setResult(false).setCode(errorCode).setMessage(message);
    }

    public static AjaxResult error(String message){
        return new AjaxResult().setResult(false).setMessage(message);
    }

}
